// 服务模块中的Web配置
package com.mask.sca.core.config;

import com.mask.sca.core.UserInfoInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer {

    private final UserInfoInterceptor userInfoInterceptor;

    public WebConfig(UserInfoInterceptor userInfoInterceptor) {
        this.userInfoInterceptor = userInfoInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(userInfoInterceptor)
            .addPathPatterns("/**")  // 拦截所有请求
            .excludePathPatterns("/public/**", "/error");  // 排除公共路径
        System.out.println("UserInfoInterceptor已注册到WebConfig");

    }
}